package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlTooth;
import com.ruoyi.hualian.service.IHlToothService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 齿形Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/tooth")
public class HlToothController extends BaseController
{
    @Autowired
    private IHlToothService hlToothService;

    /**
     * 查询齿形列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlTooth hlTooth)
    {
        startPage();
        List<HlTooth> list = hlToothService.selectHlToothList(hlTooth);
        return getDataTable(list);
    }

    /**
     * 导出齿形列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:export')")
    @Log(title = "齿形", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlTooth hlTooth)
    {
        List<HlTooth> list = hlToothService.selectHlToothList(hlTooth);
        ExcelUtil<HlTooth> util = new ExcelUtil<HlTooth>(HlTooth.class);
        util.exportExcel(response, list, "齿形数据");
    }

    /**
     * 获取齿形详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:query')")
    @GetMapping(value = "/{toothId}")
    public AjaxResult getInfo(@PathVariable("toothId") Long toothId)
    {
        return success(hlToothService.selectHlToothByToothId(toothId));
    }

    /**
     * 新增齿形
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:add')")
    @Log(title = "齿形", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlTooth hlTooth)
    {
        return toAjax(hlToothService.insertHlTooth(hlTooth));
    }

    /**
     * 修改齿形
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:edit')")
    @Log(title = "齿形", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlTooth hlTooth)
    {
        return toAjax(hlToothService.updateHlTooth(hlTooth));
    }

    /**
     * 删除齿形
     */
    @PreAuthorize("@ss.hasPermi('hualian:tooth:remove')")
    @Log(title = "齿形", businessType = BusinessType.DELETE)
	@DeleteMapping("/{toothIds}")
    public AjaxResult remove(@PathVariable Long[] toothIds)
    {
        return toAjax(hlToothService.deleteHlToothByToothIds(toothIds));
    }
}
